package com.crm.commons.domain;

import com.crm.commons.exception.BusinessException;
import com.crm.commons.exception.enumVo.ExceptionEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author junxian.dou
 * @Package：com.crm.commons.domain
 * @Project：springboot-crm
 * @name：ResponseData
 * @Date：2024/11/25 11:07
 * @Filename：ResponseData
 * @verson 1.0.0
 * @desc
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseData {
    public final static String SUCESS_MSG = "请求成功";
    public final static String ERROR_MSG = "请求失败";
    public final static Integer SUCESS_CODE = 1;
    public final static Integer ERROR_CODE = -1;

    private Integer code;
    private String message;
    private Object data;

    public ResponseData(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResponseData(Object data) {
        this.data = data;
    }

    public static ResponseData success() {
        return new SuccessResponseData();
    }

    public static ResponseData success(Object data) {
        return new SuccessResponseData(data);
    }

    public static ResponseData error() {
        return new ErrorResponseData();
    }

    public static ResponseData error(BusinessException data) {
        return new ErrorResponseData(data);
    }

    public static ResponseData error(String msg) {
        return new ErrorResponseData(msg);
    }

}
